home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <string.h>
-
- #include "DeskLib:WimpSWIs.h"
-
- #include "Shell.Array.h"
- #include "Shell.Extra.h"
- #include "Shell.SafeAlloc.h"
-
-
-
-
- typedef struct {
- Shell_GeneralArrayFn fn;
- Shell_GeneralArrayInfo info;
- }
- Shell_GeneralArrayInfoInternal;
-
-
-
-
-
- static void Shell_GeneralArrayRedrawer(
- Shell_convertpoint convert,
- wimp_point rectsize,
- void *reference,
- const wimp_rect *redrawrect
- )
- {
- wimp_rect rect = *redrawrect;
- Shell_GeneralArrayInfoInternal *info = (Shell_GeneralArrayInfoInternal *) reference;
-
- Shell_ConvertToSubTextRect2( &rect, rectsize);
-
- rect.min.x /= info->info.width;
- rect.max.x /= info->info.width;
-
-
- { int i, j;
- for ( i=rect.min.x; i<=rect.max.x; i++) {
- int x = i*Shell_TEXTXSIZE*info->info.width;
- for ( j=rect.min.y; j<=rect.max.y; j++) {
- Shell_PrintString( info->fn( i, j, &info->info),
- x, rectsize.y - j*Shell_TEXTYSIZE,
- convert);
- }
- }
- }
- return;
- }
-
-
-
-
-
- static BOOL Shell_GeneralArraySaver( char *filename, Shell_rectblock *r)
- {
- FILE *f;
- Shell_GeneralArrayInfoInternal *info = (Shell_GeneralArrayInfoInternal *) r->reference;
- int x, y;
-
- f = fopen( filename, "w");
- if (!f) return FALSE;
-
- for ( y=0; y<info->info.size.y; y++) {
- for ( x=0; x<info->info.size.x; x++) {
- fprintf( f, info->fn( x, y, &info->info));
- fprintf( f, "\t");
- }
- fprintf( f, "\n");
- }
- fclose(f);
- return TRUE;
- }
-
-
-
-
-
- Shell_rectblock *Shell_AddGeneralArray(
- Shell_windblock *windblock,
- int x, int y,
- int xsize, int ysize,
- int width,
- const char *format,
- Shell_GeneralArrayFn fn,
- const void *data,
- int forecol, int backcol
- )
-
- { wimp_rect rect;
- Shell_rectblock *r;
- Shell_GeneralArrayInfoInternal *info =
- Shell_SafeMalloc( sizeof( Shell_GeneralArrayInfoInternal));
-
- info->fn = fn;
- info->info.width = width;
- info->info.data = (void *) data;
- info->info.forecol = forecol;
- info->info.backcol = backcol;
- info->info.size.x = xsize;
- info->info.size.y = ysize;
-
- strcpy( info->info.format, format);
-
- rect.max.x = x+xsize*width*Shell_TEXTXSIZE;
- rect.max.y = y;
- rect.min.x = x;
- rect.min.y = y-ysize*Shell_TEXTYSIZE;
-
- r = Shell_AddRectangle( windblock, &rect, Shell_GeneralArrayRedrawer, (void *) info);
- r->saver = Shell_GeneralArraySaver;
- Shell_MakeRectIcon( r, forecol, backcol, "R2");
-
- return r;
- }
-
-
-